#include <GA\operations\crossing\OnePointCrosser.hpp>
#include <cstdlib>

unitraf::OnePointCrosser::OnePointCrosser(void)
{
}


unitraf::OnePointCrosser::~OnePointCrosser(void)
{
}


void unitraf::OnePointCrosser::cross ( BinaryString *BS1, BinaryString *BS2 )
{
	//point belongs to  [1, BS1->getLength( ) - 1]
	size_t point = rand( ) % ( BS1->getLength( ) - 1 ) + 1;

	bool buffer;

	//swap bits in BSs before point
	for ( size_t i = 0; i < point; ++i )
	{
		buffer = BS1->getBit( i );
		BS1->setBit( i, BS2->getBit( i ) );
		BS2->setBit( i, buffer );
	}
}
